package com.one.efaimaly.login.activity;

import android.widget.EditText;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.one.common.config.RouterPath;
import com.one.common.manager.RouterManager;
import com.one.common.utils.StringUtils;
import com.one.common.view.base.BaseActivity;
import com.one.common.view.widget.MyTitleBar;
import com.one.efaimaly.R;
import com.one.common.common.login.presenter.LoginPresenter;
import com.one.common.common.login.view.SendCodeView;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * creator: zhulunjun
 * time:    2018/8/3
 * describe: 登录界面
 */
@Route(path = RouterPath.LOGIN_PAGE)
public class LoginActivity extends BaseActivity<LoginPresenter> implements SendCodeView{
    @BindView(R.id.et_phone)
    EditText etPhone;
    @BindView(R.id.et_pwd)
    EditText etPwd;
    @BindView(R.id.tv_btn_login)
    TextView tvBtnLogin;
    @BindView(R.id.tv_forget_pwd)
    TextView tvForgetPwd;
    @BindView(R.id.tv_register)
    TextView tvRegister;

    @Override
    protected void initPresenter() {
        mPresenter = new LoginPresenter(this,this);
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_login;
    }

    @Override
    protected void initTitle() {
        super.initTitle();
        getMyTitleBar().setMode(MyTitleBar.Mode.BACK_TITLE)
                .setTitleText(StringUtils.format(R.string.login));

    }

    @OnClick(R.id.tv_register)
    public void register() {
        RouterManager.getInstance().go(RouterPath.REGISTER);
    }

    @OnClick(R.id.tv_forget_pwd)
    public void forgetPwd() {
        RouterManager.getInstance().go(RouterPath.FORGET_PWD);
    }

    @OnClick(R.id.tv_btn_login)
    public void login() {
        mPresenter.login(etPhone.getText().toString(), etPwd.getText().toString(),"2");
    }

    @Override
    public void resetCountDown() {

    }
}
